package com.summer.data.dialect.oracle;

import com.summer.data.dialect.Dialect;
import com.summer.data.dialect.DialectCenter;
import com.summer.data.dialect.DialectRouter;

/**
 * @author 345480567@qq.com
 */

public class OracleDialectRouter implements DialectRouter {

    public static final String PROD_NAME = "ORACLE";

    private static final DialectRouter ROUTER_INSTANCE = new OracleDialectRouter();

    private static final OracleDialect oracleDefaultDialect = new OracleDialect();

    private static final OracleDialect dialect8i = new OracleDialect_8i();

    private static final OracleDialect dialect9i = new OracleDialect_9i();

    private static final OracleDialect dialect12c = new OracleDialect_12c();

    @Override
    public String getName() {
        return PROD_NAME;
    }

    @Override
    public int score() {
        return 0;
    }

    @Override
    public Dialect route(int version) {
        if (version == 8) {
            return dialect8i;
        }
        if (version == 9 || version == 10) {
            return dialect9i;
        }
        if (version >= 12) {
            return dialect12c;
        }
        return oracleDefaultDialect;
    }

    static  {
        System.out.println("sql dialect 注册 : " + PROD_NAME);
        DialectCenter.regDialect(PROD_NAME, ROUTER_INSTANCE);
    }

}

